package com.yanqu.road.dao.impl.servercenter;

import com.yanqu.road.dao.db.DbNameStrategy;
import com.yanqu.road.dao.impl.TempDao;
import com.yanqu.road.entity.servercenter.AppIdPlatformPolicy;

import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.util.HashMap;
import java.util.Map;

/**
 * @author ：zfr
 * @date ：2021/11/30 11:41
 */
public class AppIdPlatformPolicyDaoImpl extends TempDao {
    public Map<String, AppIdPlatformPolicy> getAppIdPlatformPolicy() {
        ResultSet rs = null;
        CallableStatement call = null;
        String sql = "select * from t_s_appid_platform_policy";
        Map<String, AppIdPlatformPolicy> dataMap = new HashMap<>();
        try {
            getDb().setConnName(DbNameStrategy.getServerDb());
            call = getDb().getConnection().prepareCall(sql);
            rs = call.executeQuery();
            while (rs.next()) {
                AppIdPlatformPolicy data = new AppIdPlatformPolicy();
                data.setAppId(rs.getString("appId"));
                data.setUserAgreement(rs.getString("userAgreement"));
                data.setPrivacyPolicy(rs.getString("privacyPolicy"));
                dataMap.put(data.getAppId(), data);
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
            getDb().closeConnection(call, rs);
        }
        return dataMap;
    }
}
